<%@ page language="java" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
<%@ taglib uri="/tags/faare" prefix="fa" %>
<%@ taglib uri="/tags/pager" prefix="pg" %>

<HTML>
    <HEAD>
        <TITLE>Application menu and body</TITLE>
        <LINK rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/standard.css" />
    </HEAD>
    <BODY style="margin: 0; overflow: auto;" class="body_background">
        <!-- #### Horizontal Menu #### -->
        <TABLE cellpadding="0" cellspacing="0" border="0" width="100%" summary="Menu and body" class="body">
           <TR class="background">
              <TD><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="45" border="0" alt=""></TD>
              <TD width="100%">
                 <TABLE cellpadding="0" cellspacing="0" width="100%" border="0" summary="Top menu icons">
                    <TR>
                       <fa:getMenu id="Hmenu" name="horizontal_menu" />
                       <logic:iterate id="elt" name="Hmenu" property="elements">
                          <TD><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="24" height="1" alt="" border="0"></TD>
                          <TD align="center">
                             <fa:showMenuElement name="elt" style="" basecontext="page"  />
                          </TD>
                       </logic:iterate>
                    </TR>
                 </TABLE>
              </TD>
              <TD align="center">
                 <html:link action="/showPerson" paramId="dn" paramName="user" paramProperty="dn" target="_self">
                    <NOBR>&nbsp;&nbsp;&nbsp;<bean:write name="user" property="commonName" />&nbsp;&nbsp;&nbsp;</NOBR>
                 </html:link>
                 <IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="8" border="0" alt=""><BR/>
                 <logic:empty name="user" property="profile">
                    <NOBR>&nbsp;&nbsp;&nbsp;Standard profile&nbsp;&nbsp;&nbsp;</NOBR>
                 </logic:empty>
                 <logic:notEmpty name="user" property="profile">
				    <logic:notEqual name="user" property="profile" value="User">
                    <html:link action="/showProfile" paramId="dn" paramName="user" paramProperty="dn" target="_parent">
                       <NOBR>&nbsp;&nbsp;&nbsp;<bean:write name="user" property="profile" />&nbsp;&nbsp;&nbsp;</NOBR>
                    </html:link>
					</logic:notEqual>
					<logic:equal name="user" property="profile" value="User">
                       <NOBR>&nbsp;&nbsp;&nbsp;<bean:write name="user" property="profile" />&nbsp;&nbsp;&nbsp;</NOBR>
					</logic:equal>
                 </logic:notEmpty>
              </TD>
           </TR>
           <TR style="background-image: url('<%=request.getContextPath()%>/images/top_background_01.gif');">
              <TD><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="20" border="0" alt=""></TD>
              <TD width="100%" valign="middle"></TD>
              <TD width="100%" valign="middle"></TD>
           </TR>
        </TABLE>

        
        <TABLE cellpadding="0" cellspacing="20" border="0" align="center" width="100%" summary="Body" class="body">
            <TR>
               <TD valign="top">
                    <TABLE cellpadding="0" cellspacing="0" border="0" align="center" width="100%" summary="Body" class="body">
                        <TR><TD width="100%">
                                <TABLE cellpadding="0" cellspacing="0" border="0" summary="bottom" align="center">
                                    <TR><TD><IMG src="<%=request.getContextPath()%>/images/top_left_selected.gif" width="6" height="6" alt=""></TD>
                                        <TD class="background" width="100%"><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="100" height="1" alt=""></TD>
                                        <TD><IMG src="<%=request.getContextPath()%>/images/top_right_selected.gif" width="6" height="6" alt=""></TD>
                                    </TR>
                                </TABLE>
                            </TD>
                        </TR>
                        <TR>
                           <!-- #### Quick search #### -->
                           <TD class="background">
                                <DIV style="margin-left: 15;">
                                   <html:form method="post" action="/qSearch" target="_self" method="POST">
                                    <DIV class="white_title" style="margin-top: 10;">Quick&nbsp;Search</DIV>
                                    <DIV><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="15" alt=""></DIV>
                                    <TABLE cellpadding="0" cellspacing="0" border="0" summary="Quick search" class="body" width="100%">
                                        <TR>
                                           <TD width="20%">Name&nbsp;:&nbsp;</TD>
                                           <TD width="40%"><html:text property="generic" size="40" maxlength="255"/></TD>
                                           <TD align="center"><INPUT type="image" name="quick_search_button" src="<%=request.getContextPath()%>/images/search_button.gif" alt="" /></TD>
                                           <html:hidden property="generic_op" value="13" />
                                        </TR>
                                    </TABLE>
                                    <BR/>
									   <input type="hidden" name="searchType" value="quickAdvance"/>
                                    </html:form>
                                </DIV>
                            </TD>
                        </TR>
                        <TR><TD><TABLE cellpadding="0" cellspacing="0" border="0" summary="bottom" align="center">
                                    <TR><TD><IMG src="<%=request.getContextPath()%>/images/bottom_left_selected.gif" width="6" height="6" alt=""></TD>
                                        <TD class="background" width="100%"><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="100" height="1" alt=""></TD>
                                        <TD><IMG src="<%=request.getContextPath()%>/images/bottom_right_selected.gif" width="6" height="6" alt=""></TD>
                                    </TR>
                                </TABLE>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>

                <!-- #### Vertical menu #### -->
                <TD valign="top" width="200" rowspan="2">
                   <BR/>
				   &nbsp;
                </TD>
            </TR>

            <TR><TD valign="top">
                    <TABLE cellpadding="0" cellspacing="0" border="0" align="center" width="100%" summary="Body" class="body">
                        <TR><TD width="100%">
                                <TABLE cellpadding="0" cellspacing="0" border="0" summary="bottom" align="center">
                                    <TR><TD><IMG src="<%=request.getContextPath()%>/images/top_left_selected.gif" width="6" height="6" alt=""></TD>
                                        <TD class="background" width="100%"><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="100" height="1" alt=""></TD>
                                        <TD><IMG src="<%=request.getContextPath()%>/images/top_right_selected.gif" width="6" height="6" alt=""></TD>
                                    </TR>
                                </TABLE>
                            </TD>
                        </TR>
                        <TR>
                           <!-- #### Advanced search #### -->
                           <TD class="background" width="100%">
                                <DIV style="margin-left: 15;">
                                <html:form method="post" action="/search" target="_self" method="POST">
                                    <DIV class="white_title" style="margin-top: 10;">Advanced&nbsp;Search</DIV>
                                    <DIV>
                                        <IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="15" alt=""></DIV>
                                        <TABLE cellpadding="0" cellspacing="0" border="0" summary="Advanced search" class="body" width="100%">
                                            <TR><TD width="25%" height="30">First&nbsp;Name&nbsp;:&nbsp;</TD>
                                                <TD>
                                                   <fa:reflist id="refList" name="search_sn" type="operator"/>
                                                   <logic:notEmpty name="refList">
                                                      <html:select property="givenName_op">
                                                         <html:options collection="refList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                </TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <html:text property="givenName" size="30" maxlength="255"/>
                                                </TD>
                                            </TR>
                                            <TR><TD height="30">Last&nbsp;Name&nbsp;:&nbsp;</TD>
                                                <TD>
                                                   <logic:notEmpty name="refList">
                                                      <html:select property="name_op">
                                                         <html:options collection="refList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                </TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <html:text property="name" size="30" maxlength="255"/>
                                                </TD>
                                            </TR>
                                            <TR><TD height="30">User&nbsp;ID&nbsp;:&nbsp;</TD>
                                                <TD>
                                                   <logic:notEmpty name="refList">
                                                      <html:select property="id_op">
                                                         <html:options collection="refList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                </TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <html:text property="id" size="30" maxlength="255"/>
                                                </TD>
                                            </TR>
                                            <TR><TD height="30">Telephone&nbsp;Number&nbsp;:&nbsp;</TD>
                                                <TD>
                                                   <logic:notEmpty name="refList">
                                                      <html:select property="phone_op">
                                                         <html:options collection="refList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                </TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <html:text property="phone" size="30" maxlength="255"/>
                                                </TD>
                                            </TR>
                                            <TR><TD height="30">Department&nbsp;:&nbsp;</TD>
                                                <TD>&nbsp;</TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <fa:reflist id="departmentsList" name="departments" type="reflist"/>
                                                   <logic:notEmpty name="departmentsList">
                                                      <html:select property="department">
                                                         <option value=""></option>
                                                         <html:options collection="departmentsList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                   <html:hidden property="department_op" value="14" />
                                                </TD>
                                            </TR>
                                            <TR><TD height="30">Site&nbsp;:&nbsp;</TD>
                                                <TD>&nbsp;</TD>
                                                <TD>
                                                   &nbsp;&nbsp;
                                                   <fa:reflist id="sitesList" name="sites" type="reflist"/>
                                                   <logic:notEmpty name="sitesList">
                                                      <html:select property="site">
                                                         <option value=""></option>
                                                         <html:options collection="sitesList" property="value" labelProperty="label" />
                                                      </html:select>
					                               </logic:notEmpty>
                                                   <html:hidden property="site_op" value="14" />
                                                </TD>
                                            </TR>
                                            <TR><TD colspan="3" align="right">
                                                    <INPUT type="image" name="advanced_search_button" src="<%=request.getContextPath()%>/images/search_button.gif" alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                </TD>
                                            </TR>
                                        </TABLE>
                                        <BR/>
                                    </DIV>
                 						<input type="hidden" name="searchType" value="advanced"/>
                                </html:form>
                                </DIV>
                            </TD>
                        </TR>
                        <TR><TD><TABLE cellpadding="0" cellspacing="0" border="0" summary="bottom" align="center">
                                    <TR><TD><IMG src="<%=request.getContextPath()%>/images/bottom_left_selected.gif" width="6" height="6" alt=""></TD>
                                        <TD class="background" width="100%"><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="100" height="1" alt=""></TD>
                                        <TD><IMG src="<%=request.getContextPath()%>/images/bottom_right_selected.gif" width="6" height="6" alt=""></TD>
                                    </TR>
                                </TABLE>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>


            <!-- #### Search result #### -->
            <logic:present name="searchResult" scope="session">    
            <bean:size id="resultSize" name="searchResult" property="LResults" />
            <logic:equal name="resultSize" value="0">
             <TR>
               <TD colspan="2" width="100%" align="left" class="body">
                    <B><bean:write name="resultSize" /> records found</B>
               </TD>
            </TR>
            </logic:equal>
            <logic:notEqual name="resultSize" value="0">
			                   <script>
                                 function checkCancelAll()
								 {
									for (var i=0; i<document.selectionList.elements.length; i++)
									{
									   var e=document.selectionList.elements[i];
                                       if ((e.name != 'allbox') && (e.type=='checkbox'))
									   {
										   if (document.selectionList.allBox.checked)
										   {
											   e.checked=true;
										   }
										   else
										   {
											   e.checked=false;
										   }
									   }
									}

								 }

								 function doAddToCart()
								 {
									 var selectBox = document.selectionList.selectionOption;
									 userChoice = selectBox.options[selectBox.selectedIndex].value;

									 if (userChoice=="selelts")
								     {
										 document.selectionList.submit();
									 }
									 else if (userChoice=="elts")
									 {
										 document.selectionList.allBox.checked=true;
										 checkCancelAll();
										 document.selectionList.submit();
									 }
									 else if (userChoice=="all")
									 {
										 document.selectionList.action="<%=request.getContextPath()%>/addAllToCart.do";
										 document.selectionList.submit();
									 }
							     }

							  </script>
             <form name="selectionList" action="<%=request.getContextPath()%>/addToCart.do" method="POST" target="_self">
             <TR>
               <TD colspan="2" width="100%">
                    <TABLE cellpadding="0" cellspacing="0" border="0" summary="Results" width="100%" class="body">
                       <TR>
                           <TD height="40"><B><bean:write name="resultSize" /> records found</B></TD>
                           <TD align="center" width="80%">
				              <pg:pager url="<%=request.getContextPath() + \"/showSearch.do\"%>" items="<%= resultSize.intValue() %>"
					             maxPageItems="5" maxIndexPages="10" maxItems="2000"
					             export="currentPageNumber=pageNumber,offset,pagerOffset=pageOffset" scope="request">           
                                 <pg:index>
                                    <pg:first export="firstPageUrl=pageUrl" unless="current">
                                       <a href="<%= firstPageUrl %>"><img src="<%=request.getContextPath()%>/images/first.gif"  border="0"></a>
                                    </pg:first>
                                    <pg:prev export="prevPageUrl=pageUrl">
                                       <a href="<%= prevPageUrl %>"><img src="<%=request.getContextPath()%>/images/previous.gif" border="0"></a>
                                    </pg:prev>
                                    <pg:pages>
                                       <% if (pageNumber == currentPageNumber) { %> 
                                       <b><%= pageNumber %></b>
                                       <% } else { %>
                                       <a href="<%= pageUrl %>"><%= pageNumber %></a>
                                       <% } %>
                                    </pg:pages>
                                    <pg:next export="nextPageUrl=pageUrl">
                                       <a href="<%= nextPageUrl %>"><img src="<%=request.getContextPath()%>/images/next.gif" border="0"></a>
                                    </pg:next>
                                    <pg:last export="lastPageUrl=pageUrl" unless="current">
                                       <a href="<%= lastPageUrl %>"><img src="<%=request.getContextPath()%>/images/last.gif" border="0"></a>
                                    </pg:last>
                                 </pg:index>
                           </TD>
                           <TD>
                              <IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="6" height="8" border="0" alt="">
                           </TD>
                        </TR>
                        <TR>
                           <TD colspan="4">
                              <TABLE cellpadding="0" cellspacing="1" border="0" summary="Results" width="100%" class="body" style="border: solid black 1px;">							   
                                 <TR>
                                    <TH>&nbsp;First&nbsp;name&nbsp;</TH>
                                    <TH>&nbsp;Last&nbsp;name&nbsp;</TH>
                                    <TH>&nbsp;Telephone&nbsp;number&nbsp;</TH>
                                    <TH>&nbsp;Mail&nbsp;</TH>
                                    <TH>&nbsp;Job&nbsp;title&nbsp;</TH>
									<TH><input type="checkbox" name="allBox" title="Select or cancel the selection of all the displayed entries" alt="Select-Cancel" onclick="checkCancelAll()" /></TH>
                                 </TR>
		                         <logic:iterate id="tempResult" indexId="searchNum" name="searchResult" property="LResults" scope="session">
                                 <pg:item>      
		                   			<TR>
									   <TD>
									      <logic:present name="tempResult" property="givenName">
                                             <html:link action="/showPerson" paramId="dn" paramName="tempResult" paramProperty="dn" target="_self">
											    <bean:write name="tempResult" property="givenName" />
									         </html:link>
                                          </logic:present>
									   </TD>
                                       <TD>
									      <logic:present name="tempResult" property="name">
                                             <html:link action="/showPerson" paramId="dn" paramName="tempResult" paramProperty="dn" target="_self">
											    <bean:write name="tempResult" property="name" />
											 </html:link>
                                          </logic:present>
									   </TD>
                                       <TD>
									      <logic:present name="tempResult" property="phone">
										     <bean:write name="tempResult" property="phone" />
                                          </logic:present>
                                       </TD>
                                       <TD>
									      &nbsp;<A href="mailto:<bean:write name='tempResult' property='mail' />"><bean:write name='tempResult' property='mail' />&nbsp;</A>
									   </TD>
                                       <TD>
									      <logic:present name="tempResult" property="title">
										     <bean:write name="tempResult" property="title" />
                                          </logic:present>
                                       </TD>
                                       <TD width="1">
									      <input type="checkbox" name="eltindex" value="<%=searchNum%>" title="Select or cancel the selection of the entry" alt="Select-Cancel"/>
                                       </TD>
                                    </TR>
                                 </pg:item>
                                 </logic:iterate>
						 		<INPUT TYPE="HIDDEN" NAME="cartname" VALUE="panier1">    
                                <INPUT TYPE="HIDDEN" NAME="srcname"  VALUE="searchResult">     
                                <INPUT TYPE="HIDDEN" NAME="srcproperty"  VALUE="LResults"> 
                              </pg:pager>
                             </TABLE>
					      </TD>
                        </TR>
                        <TR>
			               <TD colspan="4"><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="1" height="5" alt=""></TD>
                        </TR>
                        <TR>				
               			   <TD colspan="4">
                             <TABLE cellpadding="0" cellspacing="1" border="0" summary="Results" width="100%" class="body">
					         <TR>
					            <TD align="right">
						           <select name="selectionOption">
                                      <option value ="elts">The displayed entries</option>
                                      <option value ="all">All the entries</option>
                                      <option value ="selelts">Only the selected entries</option>
                                   </select>
								   <IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="5" height="1" alt="">
							       <A href="javascript:doAddToCart();">Add selection</A>
					           </TD>
						       <TD><IMG src="<%=request.getContextPath()%>/images/spacer.gif" width="5" height="1" alt=""></TD>
					         </TR>
                             </TABLE>
                          </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
			</form>
            </logic:notEqual>
            </logic:present>
        </TABLE>
    </BODY>
</HTML>
